package com.hzw.rest;

import com.hzw.api.IAdminService;
import com.hzw.entity.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@CrossOrigin
@RequestMapping("showAdminrList")
public class AdminController {

    @Autowired
    IAdminService adminService;

    /**
     * 查询全部管理员
     * @param admin
     * @return
     */
    @PostMapping("selectAll")
    @ResponseBody
    public List<Admin> selectAll(@RequestBody Admin admin) {
        return adminService.selectAll(admin);
    }

    /**
     * .
     * 通过Id查询（回显功能）
     *
     * @return
     */
    @PostMapping("selectById")
    @ResponseBody
    public Admin selectById(@RequestBody Admin admin) {
        return adminService.selectById(admin);
    }

    /**
     * 更新管理员信息
     *
     * @param admin
     */
    @PostMapping("update")
    @ResponseBody
    public void update(@RequestBody Admin admin) {
        adminService.updateById(admin);
    }

    /**
     * 删除管理员
     *
     * @param admin
     */
    @PostMapping("delete")
    @ResponseBody
    public void delById(@RequestBody Admin admin) {
        adminService.delById(admin);
    }

    /**
     * 删除管理员
     *
     * @param admin
     */
    @PostMapping("insert")
    @ResponseBody
    public String insert(@RequestBody Admin admin) {
        return adminService.insert(admin);
    }
}
